package cn.yunbamboos.rest.service.apidoc.meta;

import cn.yunbamboos.rest.service.apidoc.IMeta;
import com.alibaba.fastjson2.JSONObject;

import java.util.HashMap;
import java.util.Map;

public class RequestBody implements IMeta {

    private final Map<String, MediaType> content = new HashMap<>();

    @Override
    public JSONObject toJSON() {
        JSONObject json = new JSONObject();

        JSONObject content = new JSONObject();
        for (Map.Entry<String, MediaType> entry : this.content.entrySet()) {
            content.put(entry.getKey(), entry.getValue().toJSON());
        }
        json.put("content", content);

        return json;
    }

    public void put(String contentType, MediaType mediaType) {
        content.put(contentType, mediaType);
    }
}
